package com.jindy.module.leaseFinancialStatistics.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.jindy.module.leaseFinancialStatistics.domain.FinancialStatisticsSearch;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jindy.common.annotation.Log;
import com.jindy.common.core.controller.BaseController;
import com.jindy.common.core.domain.AjaxResult;
import com.jindy.common.enums.BusinessType;
import com.jindy.module.leaseFinancialStatistics.domain.LeaseFinancialStatistics;
import com.jindy.module.leaseFinancialStatistics.service.ILeaseFinancialStatisticsService;
import com.jindy.common.utils.poi.ExcelUtil;
import com.jindy.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author jindy
 * @date 2023-06-06
 */
@RestController
@RequestMapping("/module/leaseFinancialStatistics")
public class LeaseFinancialStatisticsController extends BaseController
{
    @Autowired
    private ILeaseFinancialStatisticsService leaseFinancialStatisticsService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:list')")
    @GetMapping("/list")
    public TableDataInfo list(LeaseFinancialStatistics leaseFinancialStatistics)
    {
        startPage();
        List<LeaseFinancialStatistics> list = leaseFinancialStatisticsService.selectLeaseFinancialStatisticsList(leaseFinancialStatistics);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LeaseFinancialStatistics leaseFinancialStatistics)
    {
        List<LeaseFinancialStatistics> list = leaseFinancialStatisticsService.selectLeaseFinancialStatisticsList(leaseFinancialStatistics);
        ExcelUtil<LeaseFinancialStatistics> util = new ExcelUtil<LeaseFinancialStatistics>(LeaseFinancialStatistics.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:query')")
    @GetMapping(value = "/{leaseMonth}")
    public AjaxResult getInfo(@PathVariable("leaseMonth") String leaseMonth)
    {
        return AjaxResult.success(leaseFinancialStatisticsService.selectLeaseFinancialStatisticsByLeaseMonth(leaseMonth));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LeaseFinancialStatistics leaseFinancialStatistics)
    {
        return toAjax(leaseFinancialStatisticsService.insertLeaseFinancialStatistics(leaseFinancialStatistics));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LeaseFinancialStatistics leaseFinancialStatistics)
    {
        return toAjax(leaseFinancialStatisticsService.updateLeaseFinancialStatistics(leaseFinancialStatistics));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('module:leaseFinancialStatistics:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{leaseMonths}")
    public AjaxResult remove(@PathVariable String[] leaseMonths)
    {
        return toAjax(leaseFinancialStatisticsService.deleteLeaseFinancialStatisticsByLeaseMonths(leaseMonths));
    }

    /**
     * 租赁业务统计
     */
    @GetMapping("/turnover/count")
    public AjaxResult getTurnoverCount()
    {
        return leaseFinancialStatisticsService.getTurnoverCount();
    }

}
